<?php
$datype = "album";
 $i = $_GET["id"];
require_once "config.php";
require_once "engine/login.php";
require_once "engine/sort.php";
require_once "engine/func.php";

//Считывание категорий из БД
$query = "SELECT * FROM category ORDER BY caid ";
$result1 = mysql_query($query);
while($row1 = mysql_fetch_array($result1)){
   $f[] =$row1;
}
for ($x = 0; $x < count($f); $x++) {
    $category[$f[$x]["caid"]] = $f[$x];
}

//Считывание альбомов из БД    
$query = "SELECT * FROM albums ORDER BY alid ";
$res = mysql_query($query);
while($row = mysql_fetch_array($res)){
   $albums[] =$row;
}
	
$query = "SELECT * FROM albums WHERE alid='$i' ";
$qrex = mysql_query($query);
 while($row = mysql_fetch_array($qrex))
 {
   $alb[] =$row;
    }
	
$query = "SELECT * FROM news WHERE alid='$i' ORDER BY trno ";
$res = mysql_query($query);
  while($row = mysql_fetch_array($res))
 {
   $news[] =$row;
    }
 $numtracks = mysql_num_rows($res);
  
  
    
		
require 'engine/meta.php';


if(mysql_num_rows($qrex) == 1){
require 'template/'.$tpl.'/mainu.tpl';
$views =$alb[0]["views"]+1;
$i = $alb[0]["alid"];
$query = "UPDATE albums SET views='$views' WHERE alid='$i' ";
$qrex = mysql_query($query);
require 'template/'.$tpl.'/album.tpl';
 }
 else {
 $message = "По запросу ничего не найдено";
 require 'template/'.$tpl.'/mainu.tpl';
 }

require 'template/'.$tpl.'/maind.tpl';
?>
			
